package com.ruoyi.web.controller.train;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.train.domain.JyTrainingSchoolCourseMaterialSpecs;
import com.ruoyi.train.service.IJyTrainingSchoolCourseMaterialSpecsService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 培训课程物资套餐Controller
 *
 * @author aulbrother
 * @date 2024-04-06
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/train/specs")
public class JyTrainingSchoolCourseMaterialSpecsController extends BaseController {
    private final IJyTrainingSchoolCourseMaterialSpecsService jyTrainingSchoolCourseMaterialSpecsService;

    /**
     * 查询培训课程物资套餐列表
     */
    @PreAuthorize("@ss.hasPermi('train:specs:list')")
    @GetMapping("/list")
    public TableDataInfo list(JyTrainingSchoolCourseMaterialSpecs jyTrainingSchoolCourseMaterialSpecs) {
        startPage();
        List<JyTrainingSchoolCourseMaterialSpecs> list = jyTrainingSchoolCourseMaterialSpecsService.selectJyTrainingSchoolCourseMaterialSpecsList(jyTrainingSchoolCourseMaterialSpecs);
        return getDataTable(list);
    }

    /**
     * 获取培训课程物资套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('train:specs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(jyTrainingSchoolCourseMaterialSpecsService.selectJyTrainingSchoolCourseMaterialSpecsById(id));
    }

    /**
     * 修改培训课程物资套餐
     */
    @PreAuthorize("@ss.hasPermi('train:specs:edit')")
    @Log(title = "培训课程物资套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JyTrainingSchoolCourseMaterialSpecs jyTrainingSchoolCourseMaterialSpecs) {
        return toAjax(jyTrainingSchoolCourseMaterialSpecsService.updateJyTrainingSchoolCourseMaterialSpecs(jyTrainingSchoolCourseMaterialSpecs));
    }
}
